package com.ruoyi.customerSample.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.customerSample.domain.SampleCirculationBill;
import com.ruoyi.customerSample.service.ISampleCirculationBillService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 样品流转记录Controller
 * 
 * @author ruoyi
 * @date 2023-05-05
 */
@RestController
@RequestMapping("/report/circulation")
@Api(value="样品流转记录",tags = "样品流转记录接口")
public class SampleCirculationBillController extends BaseController
{
    @Autowired
    private ISampleCirculationBillService sampleCirculationBillService;

    /**
     * 查询样品流转记录列表
     */
    @GetMapping("/list")
    @ApiOperation(value="查询样品流转记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(SampleCirculationBill sampleCirculationBill)
    {
        startPage();
        List<SampleCirculationBill> list = sampleCirculationBillService.selectSampleCirculationBillList(sampleCirculationBill);
        return getDataTable(list);
    }

    /**
     * 导出样品流转记录列表
     */
    @Log(title = "样品流转记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SampleCirculationBill sampleCirculationBill)
    {
        List<SampleCirculationBill> list = sampleCirculationBillService.selectSampleCirculationBillList(sampleCirculationBill);
        ExcelUtil<SampleCirculationBill> util = new ExcelUtil<SampleCirculationBill>(SampleCirculationBill.class);
        return util.exportExcel(list, "bill");
    }

    /**
     * 获取样品流转记录详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取样品流转记录详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sampleCirculationBillService.selectSampleCirculationBillById(id));
    }

    /**
     * 新增样品流转记录
     */
    @Log(title = "样品流转记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增样品流转记录")
    public AjaxResult add(@ApiParam(name="样品流转记录",value="传入json格式",required=true)@RequestBody SampleCirculationBill sampleCirculationBill)
    {
        return toAjax(sampleCirculationBillService.insertSampleCirculationBill(sampleCirculationBill));
    }

    /**
     * 修改样品流转记录
     */
    @Log(title = "样品流转记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改样品流转记录")
    public AjaxResult edit(@ApiParam(name="样品流转记录",value="传入json格式",required=true)@RequestBody SampleCirculationBill sampleCirculationBill)
    {
        return toAjax(sampleCirculationBillService.updateSampleCirculationBill(sampleCirculationBill));
    }

    /**
     * 删除样品流转记录
     */
    @Log(title = "样品流转记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="删除样品流转记录")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sampleCirculationBillService.deleteSampleCirculationBillByIds(ids));
    }
}
